<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const userInfo = {
            id: 1,
            username: 'andy',
            age: 34,
            [Symbol('nickname')]: 'lee',
            [Symbol()]: '广州市',
            [Symbol.iterator]() {
                let cat = Reflect.ownKeys(this);
                let index = 0;
                return {
                    "next": () => {
                        if (index < cat.length) {
                            return {
                                done: false,
                                value: [cat[index], this[cat[index++]]]
                            }
                        }
                        return {
                            done: true,
                            value: '遍历返回的值'
                        }
                    }
                }
            }
        }

        for (let v of userInfo) {
            console.log(v);
        }
    </script>
</body>

</html>